#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2019/2/18 16:03
@desc
"""

import time
from threading import Semaphore, Thread


def func(sem, a, b):
    sem.acquire()
    time.sleep(3)
    print(a + b)
    sem.release()


sem = Semaphore(4)
for i in range(10):
    t = Thread(target=func, args=(sem, i, i + 5))
    print(t.getName())
    t.start()
